import { School } from '../models/school.model'
import { Injectable, Inject } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { CreateSchoolReqMessage } from 'src/service/school/types.d/createschool.response.message';
@Injectable()
export class SchoolDaoService{
  

  constructor(@InjectRepository(School) private school: Repository<School>){}

  querySchoolList(): Promise<Array<School>> {
    return this.school.find()
  }


  createOneSchool(school: CreateSchoolReqMessage): Promise<School>{
    return this.school.save(school)
  }

  queryOneSchool(id: number): Promise<School>{
    return this.school.findOne(id);
  }


  deleteOneSchool(id: number): void{
    this.school.delete(id)
    return 
  }


  patchOneSchool(school: School): void{

    this.school.save(school)

    return
  }
}